﻿using System;
using System.Collections.Generic;
using static System.Console;
using static System.Convert;

namespace Input
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("input a:");
            var a = int.Parse(Console.ReadLine());
            Console.Write("input b:");
            var b = decimal.Parse(Console.ReadLine());
            var sum = a * b;
            Console.WriteLine("The Square of the Rectangle is: {0}", sum);

            Console.WriteLine("enter your name:");
            string username = Console.ReadLine();
            Console.WriteLine("enter your age:");
            string userage = Console.ReadLine();
            Console.WriteLine("hello {0}!,you are {1} years old.", username, userage);

            int[] z = { 1, 2, 3, };
            int[] myIntArray = new int[5]{ 45, 245, 12, 55, 777 };
            Object[] myobjArray = new Object[5] { 5215,44,5,78,24};
            Console.WriteLine("Initially, integer array:");
            PrintValues(myIntArray);
            Console.WriteLine("Object array:");
            PrintValues(myobjArray);

            string[] stringArray = new string[] { "one", "two", "three" };
            Console.WriteLine("stringArray has {0} elements", stringArray.Length);

            bool[] boolArray = new bool[] { false, false, true };
            Console.WriteLine("boolArray has {0} elements", boolArray.Length);

            int[,] intArray_1 = new int[3, 4];

            string[][] c = new string[2][];
            c[0] = new string[1]; c[0][0] = "00";
            c[1] = new string[2]; c[1][0] = "01"; c[1][1] = "11";

            Array myArr = Array.CreateInstance(typeof(Int32), 2, 3, 4);
            for(int i = myArr.GetLowerBound(0); i <= myArr.GetUpperBound(0); i++)
                for(int j = myArr.GetLowerBound(1); j <= myArr.GetUpperBound(1); j++)
                    for(int k = myArr.GetLowerBound(2); k <= myArr.GetUpperBound(2); k++)
                    {
                        myArr.SetValue((i * 100) + (j * 10) + k, i, j, k);
                    }
            foreach (var i in myArr)
                WriteLine(i);
            Console.WriteLine("The Array has {0} dimension(s) and a total of {1} elements.", myArr.Rank, myArr.Length);//RANK获取 Array 的秩（维度数）。例如，一维数组返回 1，二维数组返回 2，依此类推。

            Console.WriteLine("\tLength\tLower\tUpper");
            for(int i = 0; i < myArr.Rank; i++)
            {
                Console.WriteLine("{0}:\t{1}", i, myArr.GetLength(i));
                Console.WriteLine("\t{0}\t{1}", myArr.GetLowerBound(i),myArr.GetUpperBound(i));
            }


            Console.ReadKey();
        }

        public static void PrintValues(Object[] myValues)
        {
            foreach (object i in myValues)
            {
                Console.WriteLine("\t{0}", i);
            }
            Console.WriteLine();
        }

        public static void PrintValues(int[] myValues)
        {
            foreach (int i in myValues)
            {
                Console.WriteLine("\t{0}", i);
            }
            Console.WriteLine();
        }
    }
}